package web.servlet.listthree.web;

import web.servlet.listthree.dao.UserDaoImpl;
import web.servlet.listthree.dao.UserDao;
import web.servlet.listthree.service.UserService;
import web.servlet.listthree.service.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: 18148
 * @Date: 2020-06-13 16:43:24
 */
@WebServlet("/deleteUser3Servlet")
public class DeleteUser extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String ids = req.getParameter("id");
        int id = Integer.parseInt(ids);
        UserService service=new UserServiceImpl();
        String path = req.getContextPath();
        int i = service.delete(id);
        if(i>0) {
            resp.sendRedirect(path + "/user3ListServlet");
        }
    }
}
